/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.bo;

import org.ipti.br.tag.dao.AddressFacade;
import org.ipti.br.tag.entity.Address;
import java.util.Calendar;
import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Inject;

/**
 *
 * @author israel
 */
@Stateless
public class AddressBO {
    @Inject
    private AddressFacade addressDAO;

    public AddressFacade getAddressDAO() {
        return addressDAO;
    }

    public void create(Address address) {
        getAddressDAO().create(address);
    }

    public Address createOrRefresh(Address address) {
        Long id = searchExactAddress(address);

        if (id == null || id == 0L) {
            getAddressDAO().create(address);
        }else{
            address.setId(id);
        }
        
        return address;
    }

    public void edit(Address address) {
        getAddressDAO().edit(address);
    }

    public void remove(Address address) {
        getAddressDAO().remove(address);
    }

    public Address find(Object id) {
        return getAddressDAO().find(id);
    }

    public List<Address> findAll() {
        return getAddressDAO().findAll();
    }
    
    public Long searchExactAddress(Address address) {
        return getAddressDAO().searchExactAddress(address);
    }
    
    public List<Address> modifiedAddressBetweenDate(Calendar initialDate, Calendar finalDate, Long serialNumber) {
        return getAddressDAO().modifiedAddressBetweenDate(initialDate, finalDate, serialNumber);
    }
}
